package com.lifesting.front;

import javax.faces.application.Application;
import javax.faces.context.FacesContext;
import javax.faces.render.RenderKit;

import com.sun.facelets.tag.jsf.html.AbstractHtmlLibrary;

public class FacesLib extends AbstractHtmlLibrary {
	private static final String Namespace = "http:/www.lifesting.com/jsf";
	public FacesLib() {
		super(Namespace);
		Application app =  FacesContext.getCurrentInstance().getApplication();
		app.addComponent(Table.COMPONENT_TYPE, Table.class.getName());
		app.addComponent(Rns.COMPONENT_TYPE, Rns.class.getName());
		app.addComponent(DataScroller.COMPONENT_TYPE, DataScroller.class.getName());
		app.addComponent(Column.COMPONENT_TYPE, Column.class.getName());
		app.addComponent(DeleteRowsButton.COMPONENT_TYPE, DeleteRowsButton.class.getName());
		app.addComponent(Filter.COMPONENT_TYPE, Filter.class.getName());
		app.addComponent(ProcessForm.COMPONENT_TYPE, ProcessForm.class.getName());
		app.addComponent(ProcessInput.COMPONENT_TYPE, ProcessInput.class.getName());
		app.addComponent(ProcessButton.COMPONENT_TYPE, ProcessButton.class.getName());
		
		RenderKit rk = FacesContext.getCurrentInstance().getRenderKit();
		rk.addRenderer(Table.COMPONENT_FAMILY, TableRender.RENDER_TYPE, new TableRender());
		rk.addRenderer(Table.COMPONENT_FAMILY, RnsRender.RENDER_TYPE,new RnsRender());
		rk.addRenderer(Table.COMPONENT_FAMILY, DataScrollerRender.RENDER_TYPE, new DataScrollerRender());
		rk.addRenderer(Table.COMPONENT_FAMILY, ColumnRender.RENDER_TYPE, new ColumnRender());
		rk.addRenderer(Table.COMPONENT_FAMILY, FilterRender.RENDER_TYPE, new FilterRender());
		
		addComponent("table", Table.COMPONENT_TYPE, TableRender.RENDER_TYPE, TableHandler.class);
		addComponent("rns", Rns.COMPONENT_TYPE, RnsRender.RENDER_TYPE,RnsHandler.class);
		addComponent("ds", DataScroller.COMPONENT_TYPE, DataScrollerRender.RENDER_TYPE, DataScrollerHandler.class);
		addComponent("column",Column.COMPONENT_TYPE, ColumnRender.RENDER_TYPE, ColumnHandler.class);;
		addHtmlComponent("delete",DeleteRowsButton.COMPONENT_TYPE,"javax.faces.Button");
		addComponent("filter",Filter.COMPONENT_TYPE,FilterRender.RENDER_TYPE,FilterHandler.class);
		//注册扩展BeanELResolver
		addHtmlComponent("form", ProcessForm.COMPONENT_TYPE, "javax.faces.Form");
		addHtmlComponent("input", ProcessInput.COMPONENT_TYPE, "javax.faces.Text");
		addHtmlComponent("button", ProcessButton.COMPONENT_TYPE, "javax.faces.Button");
		
	}
	
	

}
